﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HeThongDuLieu.aspx.cs"
    Inherits="Viewer.Code.HeThongDuLieu" %>

<%@ Register Src="~/Code/UserControls/UCTaoMoiLoaiMa.ascx" TagName="UCTaoMoiLoaiMa"
    TagPrefix="uc" %>
<%@ Register Src="~/Code/UserControls/UCDuLieuDetail.ascx" TagName="UCDuLieuDetail"
    TagPrefix="uc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <ext:XScript ID="XScipt1" runat="server">
    <script type="text/javascript">
         
        function ConfirmDeleteLoaiMa(id) {
            Ext.MessageBox.confirm('Thông báo', 'Bạn có chắc chắn xóa record này ko?', function doDel2(btn) {
                if (btn == 'yes') {
                    #{DirectMethods}.ShowDialog('Delete',"",id);
                }
            });
        }
    </script>
    </ext:XScript>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <div>
        <ext:Panel ID="tabNhomQuyen" runat="server" Layout="Fit" MonitorResize="true" Border="false">
            <Items>
                <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" MonitorResize="true"
                    AutoExpandColumn="GhiChu" Layout="FitLayout" Height="528" Border="false" Width="600">
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:CommandColumn Width="40" ColumnID="Command" Locked="true">
                                <Commands>
                                    <ext:GridCommand>
                                        <Menu>
                                            <Items>
                                                <ext:MenuCommand Text="Xem chi tiết" CommandName="View" Icon="LayoutHeader" />
                                                <ext:MenuCommand Text="Sửa" CommandName="Edit" Icon="ApplicationEdit" />
                                                <ext:MenuCommand Text="Xóa" CommandName="Delete" Icon="Delete" Cls="menuItemTop" />
                                            </Items>
                                        </Menu>
                                    </ext:GridCommand>
                                </Commands>
                            </ext:CommandColumn>
                            <ext:Column Header="Loại mã" DataIndex="CodeValue" Width="400" />
                            <ext:Column Header="Ghi chú" DataIndex="GhiChu" Resizable="true" />
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                    </SelectionModel>
                    <Listeners>
                        <Command Handler="if(command=='View'){#{DirectMethods}.ShowDialog('View',record.data.CodeValue,0);} else if(command=='Edit'){#{DirectMethods}.ShowDialog('Edit',record.data.CodeValue,0);}else if(command=='Delete'){ConfirmDeleteLoaiMa(record.id);}" />
                    </Listeners>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageIndex="1" PageSize="20"
                            HideRefresh="true">
                        </ext:PagingToolbar>
                    </BottomBar>
                    <TopBar>
                        <ext:Toolbar ID="Toolbar" runat="server" LabelAlign="Right">
                            <Items>
                                <ext:Button ID="btnAddNew" runat="server" Text="Tạo mới" IconAlign="Left" Icon="Add">
                                    <Listeners>
                                        <Click Handler="#{DirectMethods}.ShowDialog('AddNew','',0);" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store ID="storeHeThongDulieu" runat="server">
                            <Reader>
                                <ext:JsonReader IDProperty="CodeID">
                                    <Fields>
                                        <ext:RecordField Name="CodeKey" />
                                        <ext:RecordField Name="CodeID" />
                                        <ext:RecordField Name="CodeValue" />
                                        <ext:RecordField Name="GhiChu" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                </ext:GridPanel>
            </Items>
        </ext:Panel>
    </div>
    <uc:UCDuLieuDetail runat="server" ID="UCDuLieuDetail" />
    <uc:UCTaoMoiLoaiMa runat="server" ID="UCTaoMoiLoaiMa" />
    </form>
</body>
</html>
